package com.jxd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxd.dao.TravelInfoMapper;
import com.jxd.dao.UserMapper;
import com.jxd.model.TravelInfo;
import com.jxd.model.User;
import com.jxd.service.ITravelInfoService;
import com.jxd.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@Service
public class UserServiceImpl
        extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public HashMap<String, Object> loginService(User user) {
        HashMap<String, Object> res = new HashMap<>();
        User user1 = userMapper.selectById(user.getId());
        if (user1 != null) {
            if (user.getPassword().equals(user1.getPassword()) && Objects.equals(user.getRole(), user1.getRole())) {
                res.put("code", "200");
                res.put("user", user1);
                return res;
            }
        }
        res.put("code", "500");
        return res;
    }
}
